package com.mcc.collect.opc.utils;

import cn.hutool.core.convert.Convert;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class TimingUtil {

    public static long record(long t) {
        return record(t, null, 0);
    }

    public static long record(long t, String text) {
        return record(t, text, 0);
    }

    public static long record(long t, int limit) {
        return record(t, null, limit);
    }

    public static long record(long t, String text, int limit) {
        long now = System.currentTimeMillis();
        long diffT = now - t;
        if (diffT > limit) {
            log.info(Convert.toStr(text, "") + "耗时：" + diffT + "ms");
        }
        return now;
    }
}
